<?php
/*  get image from database
    ============================================================================================================== */
    function showImage( $id, $imgHeight="" ) {
    	if( empty( $id ) ) {
    		return null;
    	} else {
    		# get image details
    		$sql = "SELECT * FROM productImages WHERE id=" . $id;
    		$res = mysql_query ( $sql );
    		$img = mysql_fetch_array( $res );
    		$retString  = "<image src=\"/functions/getBinaryData.php?blobId=" . $id . "\"";
    		$retString .= " alt=\"" . $img['description'] . "\" ";
    		if( !empty( $imgHeight ) ) {
    			$retString .= " height=\"" . $imgHeight . "\" ";
    		}
    		$retString .= " \>";
    		return $retString;
    	}
    }


/*  show detailed product-page (input product-ID)
    ============================================================================================================== */
    function showProductDetails( $id ) {
		$sql = "SELECT * FROM product WHERE id = '" . $id . "'";
		$res = mysql_query( $sql );
		if( mysql_num_rows( $res ) == 0 ){
			echo "<p class=\"red\">Sorry. We have no product with this code. Please check the code or ask our support-team.</p>";
		} else {
		?>
		<style type="text/css">
		#productImage,
		#productPrice {
		display: none;
		}
		</style>

		<script type="text/javascript">
		$(function()
		{
			$("#showPic").click(function(event){
			event.preventDefault();
			$("#productImage").slideToggle();
		});
		
		$("#productImage a").click(function(event) {
			event.preventDefault();
		$("#productImage").slideUp();
		});
		});


		$(function()
		{
			$("#showPrice").click(function(event){
			event.preventDefault();
			$("#productPrice").slideToggle();
		});
		
		$("#productPrice a").click(function(event) {
			event.preventDefault();
		$("#productPrice").slideUp();
		});
		});
		</script>
	
		<table class="iTable">
		<?php
			$cnt = 0;
			while( $row = mysql_fetch_array( $res ) ){
				$cnt++;
				echo "<tr><td><strong>" . $row['marketingName'] . "</strong><br />";
				echo getCategoryName( $row['productCategory_id'] ) . " | #" . $row['itemNumber'];
				echo "</td></tr>\n";
				echo "<tr class=\"moreInformation\"><td><a href=\"#\" id=\"showPrice\"><img src=\"images/icons/euro.png\" align=\"absmiddle\" /> price information</a><div id=\"productPrice\"><div style=\"font-size: 2.5em; text-align: center;\">" . number_format( $row['price'], 2, ',', '' ) . "&euro;</div>";
				if( compeditorPrice( $row['id'] ) != NULL ){
					echo "<br />" . compeditorPrice( $row['id'] );
				}
				echo "</div></td></tr>\n";
#				$currentImage = getimagesize( "functions/getBinaryData.php?blobId=" . $row['productImages_id'] );
				echo "<tr class=\"lastItem moreInformation\"><td><a href=\"#\" id=\"showPic\"><img src=\"images/icons/photo.png\" align=\"absmiddle\" /> product image</a><image id=\"productImage\" width=\"100%\" src=\"/functions/getBinaryData.php?blobId=" . $row['productImages_id'] . "\" /></td></tr>\n";
			}#while
		echo "</table>";
		}#else
    }
?>